#define _CRT SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<iostream>
#include<queue>
using namespace std;

int main()
{
    string s1, s2;
    cin >> s1 >> s2;
    int len = s1.length();
    int arr[50][50] = { 0 };
    for (int i = 0; i < len; i++)
    {
        for (int j = 0; j < len; j++)
        {
            if (s1[j+1] == s2[i+1])
            {
                arr[i+1][j+1] = arr[i][j] + 1;
            }
            else
            {
                arr[i + 1][j + 1] = (arr[i][j + 1] > arr[i + 1][j]) ? arr[i][j + 1] : arr[i + 1][j];
            }
        }
    }
    cout << arr[len][len];
    return 0;
}

